All Functions Used So Far, Week 8

element_blank

{GGPLOT2}

This theme element draws nothing, and assigns no space

colnames

{base}

Retrieve column names of a data frame

prop.test

{stats}

Test of Equal or Given Proportions

mean

{base}

Get mean of a vector

class

{base}

Retrieve class of an R object

dim

{base}

Get dimensions of a data frame

addmargins

{stats}

Puts Arbitrary Margins on Multidimensional Tables or Arrays

labs

{GGPLOT2}

Customise labels in GGPLOT2

desc

{dplyr}

Arrange in descending order

ncol

{base}

Get number of columns of a data frame

expression

{base}

Used in plots to add symbols to axes

nrow

{base}

Get number of rows of a data frame

rnorm

{base}

Generate random numbers from a normal distribution

theme_classic

{GGPLOT2}

A minimalistic theme with no gridlines

geom_ribbon

{GGPLOT2}

Generates an area plot

as.data.frame

{base}

Functions to check if an object is a data frame, or coerce it if possible.

range

{base}

Return range of values

var

{stats}

Calculate variance

str

{utils}

Get the structure of an R object

read.csv

{utils}

Read a csv file to data frame. Specify stringsAsFactors = FALSE to keep all string columns as characters

complete.cases

{stats}

Find Complete Cases

names

{base}

Retrieve names of a list/vector

sum

{base}

Get sum of numeric values or a vector

get_mode

{rstatix}

Compute the mode in a given vector.

lm

{base}

Fit a linear model

attach

{base}

Attach Set of R Objects to Search Path

as.factor

{base}

Coerce a vector to factor

data.frame

{base}

Create a data.frame from vectors

theme

{GGPLOT2}

Set theme for GGPLOT2

geom_segment

{GGPLOT2}

Generates a line segment or curve

rbind

{base}

Combine R objects by rows

ungroup

{dplyr}

Resolve grouping created with “group_by”

sample_n

{dplyr}

Sample a number of observations from a data frame

cor.test

{stats}

Test for Association/Correlation Between Paired Samples

summary

{base}

Obtain summary statistics or detailed regression output

reorder

{stats}

Reorder Levels of Factor based on the values of a second variable, usually numeric.

grid.arrange

{gridExtra}

Places graphical objects into a rectangular grid

mutate

{dplyr}

Modify/create a column in a data frame

predict

{stats}

Predict Probability

ylab

{GGPLOT2}

Label the y axis (ggplot)

barplot

{graphics}

Plot a simple bar plot

tapply

{base}

Create statistical summaries by group based on the levels of one or several factors

rm

{base}

Remove objects

arrange

{dplyr}

Sort values of data frame according to a variable/combination of varaibles

setwd

{base}

Set Working Directory

ordered

{dplyr}

Create an ordered factor

order

{base}

Get indexes that will sort a vector

filter

{dplyr}

Filter out rows of a data frame according to logical vector

hist

{graphics}

Plot a simple histogram

cut

{base}

Convert Numeric to Factor

geom_hline

{GGPLOT2}

Add a horizontal line in GGPLOT2

matrix

{base}

Creates a matrix from the given set of values.

aes

{GGPLOT2}

Construct aesthetic mapping of a ggplot graph

confint

{stats}

Calculate confidence Intervals for Model Parameters

recode

{dplyr}

Recode a variable

group_by

{dplyr}

Group tibble/data.frame by a factor variable. All further tidyverse operations are performed group-wise

is.na

{base}

Check if a value is NA/elements of vector are NA

geom_bar

{GGPLOT2}

Generates a bar chart

ifelse

{base}

Return a or b depending on the value of test

geom_vline

{GGPLOT2}

Draws a vertical line

boxplot

{graphics}

Plot a simple box plot

par

{graphics}

Set parameters of the plotting device

cor

{stats}

Calculate Correlation Matrix

table

{base}

Obtain frequency table of a variable/cross-tabulation of two variables

ggtitle

{GGPLOT2}

Generates a title for a ggplot graph

runif

{stats}

Draws ranndom numbers from the uniform distribution

element_text

{GGPLOT2}

Customise text in GGPLOT2

rbeta

{stats}

Beta Random Number Generating Function

scale_colour_manual

{GGPLOT2}

Create your own discrete scale

pie

{graphics}

Creates a basic pie chart

scale_x_continuous

{GGPLOT2}

Customise continuous x axis

after_stat

{GGPLOT2}

Control aesthetic evaluation. On the module used for displying percent

summarise

{dplyr}

collapse the dataset to a summary statistic. Usually used with group_by()

freq

{questionr}

Generate frequency tables

chisq.test

{stats}

Chi-Squared test (e.g. for cross-tabulations)

bar

{base}

Used for annotations, such as “expression(paste(”-“,bar(y)))”

tabulate

{base}

Counts the number of times each integer occurs in an integer-only vector

geom_smooth

{GGPLOT2}

Generates a smoothed conditional means curve / line

geom_density

{GGPLOT2}

Generates a density plot

stargazer

{stargazer}

Create a regression output table

read_excel

{readxl}

Read an Excel file

cbind

{base}

Combine R objects by columns

scale_y_continuous

{GGPLOT2}

Customise continuous y axis

which

{base}

return indexes of TRUE entries of a logical vector

arrow

{GGPLOT2}

Draw an arrow in a ggplot graph

c

{base}

Combine values/vectors into a vector

round

{base}

Rounds numbers

geom_histogram

{GGPLOT2}

Generates a histogram

library

{base}

Load an R package

select

{dplyr}

Select columns from a tibble/data frame

dnorm

{stats}

Density distribution for the normal distribution

sd

{stats}

Get standard deviation of a vector

unique

{base}

get unique elements

read.spss

{foreign}

Read a .sav file (SPSS data)

View

{base}

View a data frame

print

{base}

Print object to the console

factor

{base}

Create a factor

levels

{base}

Get levels of a factor

theme_bw

{GGPLOT2}

A black and white ggplot theme

lprop

{questionr}

Display row percentages of a two-way frequency table

min

{base}

Get minimum of a vector

t.test

{stats}

Performs one and two sample t-tests on vectors of data.

set.seed

{base}

Initialise a pseudorandom number generator.

sample

{base}

Takes a sample of the specified size

install.packages

{base}

Install R package

seq

{base}

Create a sequence

ls.str

{utils}

Similarly to ls, with a print() method that calls str() on each object

with

{base}

evaluate expression in the context of a data frame

quantile

{stats}

Obtain empirical quantiles of a vector

head

{utils}

Show first 5 rows of a data frame

ls

{base}

Return a vector of character strings giving the names of the objects in the specified environment

as.numeric

{base}

Coerce a vector to numeric

subset

{base}

Return subsets of vectors, matrices or data frames which meet conditions.

xlab

{GGPLOT2}

Label the x axis (ggplot)

ggplot

{GGPLOT2}

Create a ggplot graph

coord_flip

{GGPLOT2}

Flip the x and y axes of a graph

median

{stats}

Get median of a vector

slice

{dplyr}

Subset rows using their positions

which.max

{base}

return index of the largest value in a vector

max

{base}

Get maximum of a vector

prop.table

{base}

Transform frequency table into table of proportions

geom_point

{GGPLOT2}

Generates a scatter plot

plot

{graphics}

Generic function from base R to produce a plot

The end!